<?php

/**
 * Use Txt2tags Markup in PmWiki (doesn't work)
 * 
 * @author based on Sebastian Siedentopf <schlaefer@macnews.de> rules for markdown
 * @version 0.1
 * @link http://www.pmwiki.org/wiki/Cookbook/Txt2tagsMarkupExtension http://www.pmwiki.org/wiki/Cookbook/Txt2tagsMarkupExtension
 * @copyright by the respective authors 2006
 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
 * @package txt2tagspmw
 */

define(TXT2TAGSPMW, "0.1");

SDVA($PmWikiAutoUpdate['Txt2tagsPmW'], array(
    'version' => TXT2TAGSPMW, 
    'updateurl' => 'http://www.pmwiki.org/wiki/Cookbook/Txt2tagsMarkupExtension',
));

include_once("txt2tags.class.php");

Markup("txt2tags", '<fulltext', "/(.*?)/se", 
    "Keep(MarkupPmWikiConversion(PSS('$1')))");

function MarkupPmWikiConversion($text){
    $astr = array (
            "<:vspace>" => "\n\n",
            "(:nl:)" => "\n",
        );
    $pstr = array(
            "/<p>/" => "<p class='vspace'>",
            "/&amp;(.*?);/" => "&\\1;",
        );
        
    //$text = str_replace(array_keys($astr), $astr, $text); 
    //$text = Txt2tags($text);
    $x = new T2T($text);
    $x->go();
    $text = $x->bodyhtml;
    
    //$text = preg_replace(array_keys($pstr), $pstr, $text); 
        
    return $text;
    }

?>
